<?php
if(!defined('BZ_XTBLOG')){
    exit('Access Denied!');
}
class ubb{
	function index_ubb($content){
		global $db;
    $time=date("H:i:s");
    $date=date("Y-m-d");
    $now=date("Y-m-d H:i:s");
$content=preg_replace("/\[banben]/",Bingz_banben(), $content );
$content=preg_replace("/\[div=(.+?)\]/","<div class='\\1'>", $content );
$content=preg_replace("/\[\/div\]/","</div>", $content );
$content=str_replace ("[hr/]","<hr/>",$content);
$content=preg_replace("/\[\/b\]/","</b>", $content );
$content=preg_replace("/\[b\]/","<b>", $content );
$content=preg_replace("/\[\/u\]/","</u>", $content );
$content=preg_replace("/\[u\]/","<u>", $content );
$content=preg_replace("/\[\/i\]/","</i>", $content );
$content=preg_replace("/\[i\]/","<i>", $content );
$content=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/","<font color=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/","<font size=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[center\](.+?)\[\/center\]/","<p align=center>\\1</p>",$content);
$content=preg_replace("/\[left\](.+?)\[\/left\]/","<p align=left>\\1</p>",$content);
$content=preg_replace("/\[right\](.+?)\[\/right\]/","<p align=right>\\1</p>",$content);
$content=preg_replace("/\[ys=(.+?)\](.+?)\[\/ys\]/","<font color=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[img=(.+?)\](.+?)\[\/img\]/","<img src=\"\\1\" alt=\"\\2\">",$content);
$content=preg_replace("/\[img](.+?)\[\/img\]/","<img src=\"\\1\">",$content);
$content=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/","<a href=\"\\1\">\\2</a>",$content);
$content=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/","<a href=\"\\1\">\\2</a>",$content);
$content=preg_replace("/\[wbdt](.+?)\[\/wbdt\]/","<marquee  behavior=\"scroll\" scrollamount=\"2\" onMouseOut=\"this.start()\" onMouseOver=\"this.stop()\">\\1</marquee>",$content);
$content=preg_replace("/\[br\/\]/","<br/>", $content );//换行
$content=preg_replace("/\[br\]/","<br/>", $content );//换行
$content=preg_replace("/\/\/\//","<br/>", $content );//换行
$content=preg_replace("/\[tab\]/","&nbsp;", $content );//空格
$content=preg_replace("/\[date\]/","$date", $content );//替换日期标签
$content=preg_replace("/\[time\]/","$time", $content );//替换时间标签
$content=preg_replace("/\[now\]/","$now", $content );//替换日期时间
$content=preg_replace("/\[\/b\]/","</b>", $content );
$content=preg_replace("/\[b\]/","<b>", $content );
$content=preg_replace("/\[\/u\]/","</u>", $content );
$content=preg_replace("/\[u\]/","<u>", $content );
$content=preg_replace("/\[\/i\]/","</i>", $content );
$content=preg_replace("/\[i\]/","<i>", $content );
$content=str_replace("&amp;","&",$content);
$content=str_replace("&","&amp;",$content);
##################插件ubb
while(preg_match("/\[plugin=(.*?)#(.*?)\]/",$content,$link)){
	    if($db->get_one('plugin',"`identifier` ='$link[1]' and `available` = '1' ",'')){
         $plugin=$db->get_one('pluginubb',"`identifier` ='$link[1]' and `name` = '$link[2]' ",'');
	       if($plugin && function_exists($link[2])){
            $content=str_replace($link[0],$link[2](),$content);
         }else{
      	    $content=str_replace($link[0],'',$content);
         }
      }else{
      	    $content=str_replace($link[0],'',$content);
      }
	if(!preg_match("/\[plugin=(.*?)#(.*?)\]/",$content))
		break;
}
while(preg_match("/\[forum=([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})\]/",$content)){
	preg_match("/\[forum=([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})\]/",$content,$links);
	$out_links=forum_class($links[1],$links[2],$links[3],$links[4]);
	$content=str_replace($links[0],$out_links,$content);
	if(!preg_match("/\[forum=([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})_([0-9]{1,3})\]/",$content))
		break;
}
while(preg_match("/\[user=([0-9]{1,3})_([0-9]{1})\]/",$content)){
	preg_match("/\[user=([0-9]{1,3})_([0-9]{1})\]/",$content,$hy);
	$out_hy=user_class($hy[1],$hy[2],$hy[3]);
	$content=str_replace($hy[0],$out_hy,$content);
	if(!preg_match("/\[user=([0-9]{1,3})_([0-9]{1})\]/",$content))
		break;
}
while(preg_match("/\[link=([0-9]{1,3})_([0-9]{1})_([0-9]{1})\]/",$content)){
	preg_match("/\[link=([0-9]{1,3})_([0-9]{1})_([0-9]{1})\]/",$content,$links);
	$out_links=link_class($links[1],$links[2],$links[3]);
	$content=str_replace($links[0],$out_links,$content);
	if(!preg_match("/\[link=([0-9]{1,3})_([0-9]{1})_([0-9]{1})\]/",$content))
		break;
}
return $content;
}
	function content_ubb($content){
	  global $db,$Bingz_contentth,$Bingz_contentgl;
		$date=date("Y-m-d");
		$time=date("H:i:s");
		$now =date("Y-m-d H:i:s");
  if(preg_match_all("/\[daima\](.*?)\[\/daima\]/s",$content,$daim)){
        $daim[1]=array_unique($daim[1]);
        foreach( $daim[1] as $a=> $val){
     	     $daimam=authcode($val,'ok');
    	     $content=str_replace($daim[0][$a],'[daima]'.$daimam.'[/daima]',$content);
    	  }
  }
$content=strip_tags($content);
$content=preg_replace('/\s{5,}/','<br/>',$content);
$content=preg_replace("/\r\n/", "<br/>", $content); 
$content=preg_replace("/\[\/b\]/","</b>", $content );
$content=preg_replace("/\[b\]/","<b>", $content );
$content=preg_replace("/\[\/u\]/","</u>", $content );
$content=preg_replace("/\[u\]/","<u>", $content );
$content=preg_replace("/\[\/i\]/","</i>", $content );
$content=preg_replace("/\[i\]/","<i>", $content );
$content=preg_replace("/\[div=(.+?)\](.+?)\[\/div\]/","<div class=\"\\1\">\\2</div>",$content);
$content=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/","<font color=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/","<font size=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[center\](.+?)\[\/center\]/","<p align=center>\\1</p>",$content);
$content=preg_replace("/\[left\](.+?)\[\/left\]/","<p align=left>\\1</p>",$content);
$content=preg_replace("/\[right\](.+?)\[\/right\]/","<p align=right>\\1</p>",$content);
$content=preg_replace("/\[ys=(.+?)\](.+?)\[\/ys\]/","<font color=\"\\1\">\\2</font>",$content);
$content=preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/","<a href=\"\\1\">\\2</a>",$content);
$content=preg_replace("/\[img=(.+?)\](.+?)\[\/img\]/","<img src=\"\\1\" alt=\"\\2\">",$content);
$content=preg_replace("/\[img](.+?)\[\/img\]/","<img src=\"\\1\">",$content);
$content=preg_replace("/\[br\/\]/","<br/>", $content );//换行
$content=preg_replace("/\[br\]/","<br/>", $content );//换行
$content=preg_replace("/\/\/\//","<br/>", $content );//换行
$content=preg_replace("/\[tab\]/","&nbsp;", $content );//空格
$content=preg_replace("/\[date\]/","$date", $content );//替换日期标签
$content=preg_replace("/\[time\]/","$time", $content );//替换时间标签
$content=preg_replace("/\[now\]/","$now", $content );//替换日期时间
$content=str_replace("&amp;","&",$content);
$content=str_replace("&","&amp;",$content);

  if(preg_match_all("/@(.*?)(?:[,| ])/",$content,$smsoon)){
        $smsoon[1]=array_unique($smsoon[1]);
        foreach( $smsoon[1] as $a=> $val){
	       if($nnmm=$db->get_one('user'," `name` = '$val' ",'uid')){
	        	$smsoofja='<a href="index.php?m=user&uid='.$nnmm[uid].'"><font color="#C2C2C2">@'.$val.'</font></a> ';
     	      $content=str_replace($smsoon[0][$a],$smsoofja,$content);
     	   }
       }
  }
  if(preg_match_all("/\[s:(.*?)\]/",$content,$biaoq)){
        $biaoq[1]=array_unique($biaoq[1]);
        foreach( $biaoq[1] as $a=> $val){
	        if($msms=$db->get_one('emotion'," `emotion_name` = '$val'",'')){
	          $msmsgg='<img src="images/smiley/'.$msms[emotion_folder].'/'.$msms[emotion_icon].'" alt="$msms[emotion_name]" width="50" height="50" />';
          }
	        $content=str_replace($biaoq[0][$a],$msmsgg,$content);
       }
  }
  if(preg_match_all("/\[daima\](.*?)\[\/daima\]/s",$content,$daima)){
        $daima[1]=array_unique($daima[1]);
        foreach( $daima[1] as $a=> $val){
    	    $daimaa=authcode($val,$operation='DECODE');
    	    $daimam=htmlspecialchars($daimaa);
    	    $daimam=preg_replace("/\r\n/", "<br/>", $daimam); 
    	    $content=str_replace($daima[0][$a],'<div class="daima">'.$daimam.'</div>',$content);
    	  }
  }
  ###########
  $ArrFiltrate=explode(',',$Bingz_contentgl);
  foreach ($ArrFiltrate as $key){
       if (@eregi($key,$content)){
          $content=str_replace($key,$Bingz_contentth,$content);
       }
  }
  return $content;
	}
}
$ubb=new ubb();
?>
